package 代码随想2._3哈希表;

/**
 * @author XXX
 * @date 2024-01-14 21:48
 */

/**
 * https://leetcode.cn/problems/ransom-note/description/
 */
public class _6赎金信 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] dic = new int[26];
        for(int i=0; i<magazine.length();i++)
            dic[magazine.charAt(i) - 'a']++;
        for(int i=0; i<ransomNote.length();i++){
            dic[ransomNote.charAt(i)-'a']--;
            if(dic[ransomNote.charAt(i)-'a']<0)
                return false;
        }
        return true;
    }
}
